<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<meta name="keywords" content="Nacos,服务,发现,性能" />
	<meta name="description" content="Nacos2.0服务发现性能测试报告" />
	<!-- 网页标签标题 -->
	<title>Nacos2.0服务发现性能测试报告</title>
	<link rel="shortcut icon" href="https://img.alicdn.com/tfs/TB1hgJpHAPoK1RjSZKbXXX1IXXa-64-64.png"/>
	<link rel="stylesheet" href="/build/documentation.css" />
</head>
<body>
	<div id="root"><div class="documentation-page" data-reactroot=""><header class="header-container header-container-normal"><div class="header-body"><a href="/en-us/index.html"><img class="logo" src="/img/nacos_colorful.png"/></a><div class="search search-normal"><span class="icon-search"></span></div><span class="language-switch language-switch-normal">中</span><div class="header-menu"><img class="header-menu-toggle" src="/img/menu_gray.png"/><ul><li class="menu-item menu-item-normal"><a href="/en-us/index.html">HOME</a></li><li class="menu-item menu-item-normal menu-item-normal-active"><a href="/en-us/docs/quick-start.html">DOCS</a></li><li class="menu-item menu-item-normal"><a href="/en-us/blog">BLOG</a></li><li class="menu-item menu-item-normal"><a href="/en-us/community">COMMUNITY</a></li><li class="menu-item menu-item-normal"><a href="https://cn.aliyun.com/product/aliware/mse?spm=nacos-website.topbar.0.0.0">NACOS IN CLOUD</a><img class="menu-img" src="https://img.alicdn.com/tfs/TB1esl_m.T1gK0jSZFrXXcNCXXa-200-200.png"/></li><li class="menu-item menu-item-normal"><a href="http://console.nacos.io/nacos/index.html">DEMO-CONSOLE</a></li></ul></div></div></header><div class="bar"><div class="bar-body"><img src="/img/docs.png" class="front-img"/><div class="bar-title"><span>Documentation</span><div class="bone bone-light"></div></div><img src="/img/docs.png" class="back-img"/></div></div><section class="content-section"><div class="content-body"><div class="sidemenu"><div class="sidemenu-toggle"><img src="https://img.alicdn.com/tfs/TB1E6apXHGYBuNjy0FoXXciBFXa-200-200.png"/></div><ul><li class="menu-item menu-item-level-1"><span>Nacos </span><ul><li style="height:180px;overflow:hidden" class="menu-item menu-item-level-2"><span>What is Nacos<img style="transform:rotate(0deg)" class="menu-toggle" src="/img/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/en-us/docs/what-is-nacos.html" target="_self">What is Nacos</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/concepts.html" target="_self">Concepts</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/architecture.html" target="_self">Architecure</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/feature-list.html" target="_self">Feature list</a></li></ul></li><li style="height:324px;overflow:hidden" class="menu-item menu-item-level-2"><span>Quick Start<img style="transform:rotate(0deg)" class="menu-toggle" src="/img/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/en-us/docs/quick-start.html" target="_self">Nacos</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/quick-start-spring.html" target="_self">Nacos Spring</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/quick-start-spring-boot.html" target="_self">Nacos Spring Boot</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/quick-start-spring-cloud.html" target="_self">Nacos Spring Cloud</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/quick-start-docker.html" target="_self">Nacos Docker</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/use-nacos-with-dubbo.html" target="_self">Nacos with Dubbo</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/use-nacos-with-kubernetes.html" target="_self">Nacos with K8s</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/nacos-sync.html" target="_self">Nacos Sync</a></li></ul></li><li style="height:288px;overflow:hidden" class="menu-item menu-item-level-2"><span>User Guide<img style="transform:rotate(0deg)" class="menu-toggle" src="/img/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/en-us/docs/sdk.html" target="_self">Java SDK</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/other-language.html" target="_self">Other Language</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/open-api.html" target="_self">Open-API</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/nacos-spring.html" target="_self">Nacos Spring</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/system-configurations.html" target="_self">Nacos System Configurations</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/auth.html" target="_self">Authentication</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/faq.html" target="_self">FAQ</a></li></ul></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><span>Admin Guide<img style="transform:rotate(-90deg)" class="menu-toggle" src="/img/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/en-us/docs/deployment.html" target="_self">Deployment Guide</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/cluster-mode-quick-start.html" target="_self">Cluster Mode Deployment</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/management-api.html" target="_self">Management OpenAPI</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/console-guide.html" target="_self">Admin Console Guide</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/monitor-guide.html" target="_self">Nacos Monitor Guide</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/nacos-config-benchmark.html" target="_self">Nacos Config Benchmark</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/nacos2-config-benchmark.html" target="_self">Nacos2.0 Config Benchmark</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/nacos-naming-benchmark.html" target="_self">Nacos Naming Benchmark</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/nacos2-naming-benchmark.html" target="_self">Nacos2.0 Naming Benchmark</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/nacos-sync-use.html" target="_self">Data Migration to Nacos</a></li></ul></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><span>Nacos 2.0<img style="transform:rotate(-90deg)" class="menu-toggle" src="/img/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/2.0.0-alpha.html" target="_self">2.0-BETA</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/2.0.0-upgrading.html" target="_self">Upgrading</a></li></ul></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><span>Contributor Guide<img style="transform:rotate(-90deg)" class="menu-toggle" src="/img/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/en-us/docs/contributing.html" target="_self">Contribute to Nacos</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/contributing-flow.html" target="_self">Contributing Flow</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/pull-request.html" target="_self">Pull Request Template</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/how-to-reporting-bugs.html" target="_self">How to report bugs</a></li></ul></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><span>Community<img style="transform:rotate(-90deg)" class="menu-toggle" src="/img/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/en-us/docs/community.html" target="_self">Community</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/nacos-dev.html" target="_self">Develop Team</a></li></ul></li></ul></li></ul></div><div class="doc-content markdown-body"><h1>Nacos2.0.0-ALPHA2 服务发现性能测试报告</h1>
<h2>测试目的</h2>
<p>Nacos2.0对连接模型，服务发现的数据模型也运作模式进行了大范围的重构，因此需要在相同或类似的场景下，了解Nacos2的服务发现性能负载和容量与Nacos1的区别，帮助用户更快的运用评估Nacos系统负荷。</p>
<p>Nacos1.0性能测试参考 <a href="https://nacos.io/zh-cn/docs/nacos-naming-benchmark.html">服务发现性能测试报告</a></p>
<h2>测试工具</h2>
<p>我们使用自研的PAS性能评估服务平台进行压测，其原理是基于利用JMeter引擎，使用PAS自动生成的JMeter脚本，进行智能压测。</p>
<p><img src="https://img.alicdn.com/tfs/TB1xCfDDpzqK1RjSZFvXXcB7VXa-692-297.png" alt="Pas图"></p>
<h2>测试环境</h2>
<h3>1. 环境</h3>
<table>
<thead>
<tr>
<th><strong>指标</strong></th>
<th><strong>参数</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>机器</td>
<td>CPU 8核，内存16G</td>
</tr>
<tr>
<td>集群规模</td>
<td>3节点</td>
</tr>
<tr>
<td>Nacos版本</td>
<td>服务端：Nacos2.0.0-ALPHA2， 客户端：Nacos2.0.0-ALPHA2</td>
</tr>
</tbody>
</table>
<h3>2.设置启动参数</h3>
<pre><code>${JAVA_HOME}/bin/java -DembeddedStorage=true -server -Xms10g -Xmx10g -Xmn4g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/admin/nacos/logs/java_heapdump.hprof -XX:-UseLargePages -Dnacos.member.list= -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${JAVA_HOME}/lib/ext -Xloggc:/home/admin/nacos/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -Dloader.path=/home/admin/nacos/plugins/health,/home/admin/nacos/plugins/cmdb -Dnacos.home=/home/admin/nacos -jar /home/admin/nacos/target/nacos-server.jar --spring.config.additional-location=file:/home/admin/nacos/conf/ --logging.config=/home/admin/nacos/conf/nacos-logback.xml --server.max-http-header-size=524288 nacos.nacos
</code></pre>
<h2>测试场景</h2>
<p>以下测试场景都是服务发现重要接口：</p>
<ul>
<li>验证Nacos服务发现注册实例的能力</li>
<li>验证Nacos服务发现查询实例的能力</li>
<li>验证Nacos服务发现注销实例的能力</li>
</ul>
<h2>测试数据</h2>
<h3>1. 注册实例</h3>
<p>施压机模拟100个客户端同时发起注册服务，每个客户端一条长连接，每个客户端注册1W个服务。总数100W个服务及实例。</p>
<p>注册完成之后每个客户端继续不停进行注册请求，模拟重复注册请求（会进行更新替换），同时记录下整个过程中的相关数据。</p>
<h4>相关API</h4>
<p><code>NamingService.registerInstance(String serviceName, Instance instance)</code></p>
<h4>结果数据如下</h4>
<table>
<thead>
<tr>
<th>施压机数量</th>
<th>每台线程数</th>
<th>平均TPS</th>
<th>平均RT</th>
<th>最小RT</th>
<th>最大RT</th>
<th>80%RT(ms)</th>
<th>95%RT(ms)</th>
<th>99%RT(ms)</th>
<th>CPU使用率</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>100</td>
<td>7256.32</td>
<td>13.14</td>
<td>0.39</td>
<td>2522.25</td>
<td>6.72</td>
<td>12.86</td>
<td>126.33</td>
<td>80%</td>
</tr>
<tr>
<td>2</td>
<td>50</td>
<td>16418.04</td>
<td>5.8</td>
<td>0.41</td>
<td>3906.77</td>
<td>4.0</td>
<td>8.88</td>
<td>48.84</td>
<td>90%</td>
</tr>
<tr>
<td>5</td>
<td>20</td>
<td>26784.84</td>
<td>3.6</td>
<td>0.38</td>
<td>1606.41</td>
<td>3.82</td>
<td>8.91</td>
<td>30.62</td>
<td>90%</td>
</tr>
</tbody>
</table>
<h4>结果分析</h4>
<p>相较Nacos1.X版本，注册性能总体提升至少2倍，在服务端机能减半的情况下，服务实例数基本一致的情况下，TPS仍能做到2倍左右的提高。</p>
<h3>2. 查询实例</h3>
<p>施压机先模拟发起注册服务，总数10W个服务，每个服务10个实例，总数100W实例。</p>
<p>注册完成后，模拟100个客户端同时不停进行随机服务查询请求，并且有实例长度校验。同时记录下整个过程中的相关数据。</p>
<h4>相关API</h4>
<p><code>NacosNamingService.getAllInstances(String serviceName, boolean subscribe)</code></p>
<p><strong>注意</strong> subscribe 为 false 进行测试，否则将会优先查询客户端缓存。</p>
<h4>结果数据如下</h4>
<table>
<thead>
<tr>
<th>施压机数量</th>
<th>每台线程数</th>
<th>平均TPS</th>
<th>平均RT</th>
<th>最小RT</th>
<th>最大RT</th>
<th>80%RT(ms)</th>
<th>95%RT(ms)</th>
<th>99%RT(ms)</th>
<th>CPU使用率</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>100</td>
<td>12998.46</td>
<td>7.54</td>
<td>0.55</td>
<td>213.86</td>
<td>9.68</td>
<td>10.69</td>
<td>27.92</td>
<td>40%</td>
</tr>
<tr>
<td>2</td>
<td>50</td>
<td>12785.01</td>
<td>7.93</td>
<td>0.38</td>
<td>900.48</td>
<td>8.34</td>
<td>14.18</td>
<td>33.04</td>
<td>40%</td>
</tr>
<tr>
<td>2</td>
<td>100</td>
<td>18451.78</td>
<td>10.63</td>
<td>0.6</td>
<td>829.42</td>
<td>11.95</td>
<td>23.79</td>
<td>44.19</td>
<td>45%</td>
</tr>
<tr>
<td>5</td>
<td>20</td>
<td>30680.48</td>
<td>3.12</td>
<td>0.46</td>
<td>1138.38</td>
<td>4.33</td>
<td>5.9</td>
<td>9.57</td>
<td>50%</td>
</tr>
</tbody>
</table>
<h4>结果分析</h4>
<p>相较Nacos1.X版本，查询性能总体提升至少3倍，在服务端机能减半的情况下，服务实例数基本一致的情况下，TPS仍能做到3倍左右的提高，单机多线程场景甚至有10倍的提升。</p>
<h3>3. 注销实例</h3>
<p>施压机先模拟100个客户端同时发起注册服务，每个客户端一条长连接，每个客户端注册1W个服务。总数100W个服务及实例。</p>
<p>注册完成后，模拟使用相同100个客户端同时不停进行随机服务注销请求，同时记录下整个过程中的相关数据。</p>
<h4>相关API</h4>
<p><code>NacosNamingService.deregisterInstance(String serviceName, String ip, int port)</code></p>
<h4>结果数据如下</h4>
<table>
<thead>
<tr>
<th>施压机数量</th>
<th>每台线程数</th>
<th>平均TPS</th>
<th>平均RT</th>
<th>最小RT</th>
<th>最大RT</th>
<th>80%RT(ms)</th>
<th>95%RT(ms)</th>
<th>99%RT(ms)</th>
<th>CPU使用率</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>100</td>
<td>9614.96</td>
<td>9.88</td>
<td>0.41</td>
<td>1115.27</td>
<td>8.85</td>
<td>15.32</td>
<td>104.76</td>
<td>70%</td>
</tr>
<tr>
<td>2</td>
<td>50</td>
<td>22252.07</td>
<td>4.28</td>
<td>0.39</td>
<td>856.1</td>
<td>4.03</td>
<td>5.65</td>
<td>31.02</td>
<td>90% -&gt; 60%</td>
</tr>
<tr>
<td>5</td>
<td>20</td>
<td>29393.8</td>
<td>2.55</td>
<td>0.42</td>
<td>741.09</td>
<td>2.67</td>
<td>8.91</td>
<td>15.85</td>
<td>90% -&gt; 60%</td>
</tr>
</tbody>
</table>
<h4>结果分析</h4>
<p>相较Nacos1.X版本，注销性能总体提升至少2倍，在服务端机能减半的情况下，服务实例数基本一致的情况下，TPS仍能做到2倍左右的提高。
关于CPU由90% 降低为 60%的场景， 是由于随着注销的的服务和实例增多，重复注销的操作变得频繁，未命中服务和实例的操作会被快速返回且操作量小，因此CPU下降、TPS相对注册略高。</p>
<h2>测试结论</h2>
<p>Nacos2服务发现性能测试都是针对重点功能，通过对3节点规模集群进行压测，可以看到接口性能负载和容量，以及对比相同/类似场景下Nacos1.X版本的提升。</p>
<ol>
<li>压测时服务及实例容量达到百万级，集群运行持续稳定，达到预期；（该场景没有计算频繁变更导致的频繁推送内容，仅单纯计算容量上线，附带推送的真实场景将在下轮压测报告中给出）</li>
<li>注册/注销实例TPS达到 26000 以上，总体较Nacos1.X提升至少2倍，接口达到预期；</li>
<li>查询实例TPS能够达到 30000 以上，总体较Nacos1.X提升3倍左右，接口达到预期；</li>
</ol>
<p><strong>注意</strong></p>
<ul>
<li>本次只测试临时实例注册/查询/注销，未涉及持久实例；</li>
<li>本测试为对比Nacos1.X版本的测试场景，仅测试单核心接口的能力值，<strong>真实模拟场景压测</strong> 将在后续版本给出；</li>
<li>本测试供给大家作为参考，如有不足或偏差，请指正! 如果对性能有其他需求，可以给我们提issue。</li>
</ul>
</div></div></section><footer class="footer-container"><div class="footer-body"><img src="/img/nacos_gray.png"/><div class="cols-container"><div class="col col-12"><h3>Vision</h3><p>By providing an easy-to-use service infrastructure such as dynamic service discovery, service configuration, service sharing and management and etc., Nacos help users better construct, deliver and manage their own service platform, reuse and composite business service faster and deliver value of business innovation more quickly so as to win market for users in the era of cloud native and in all cloud environments, such as private, mixed, or public clouds.</p></div><div class="col col-6"><dl><dt>Documentation</dt><dd><a href="/en-us/docs/what-is-nacos.html" target="_self">Overview</a></dd><dd><a href="/en-us/docs/quick-start.html" target="_self">Quick start</a></dd><dd><a href="/en-us/docs/contributing.html" target="_self">Developer guide</a></dd></dl></div><div class="col col-6"><dl><dt>Resources</dt><dd><a href="/en-us/community/index.html" target="_self">Community</a></dd><dd><a href="https://cn.aliyun.com/product/aliware/mse?spm=nacos-website.topbar.0.0.0" target="_self">Cloud Service MSE</a></dd><dd><a href="https://www.aliyun.com/product/edas?source_type=nacos_pc_20181219" target="_self">Cloud Service EDAS</a></dd><dd><a href="https://www.aliyun.com/product/ahas?source_type=nacos_pc_20190225" target="_self">Cloud Service AHAS</a></dd></dl></div></div><div class="copyright"><span>@ 2018 The Nacos Authors | An Alibaba Middleware (Aliware) Project</span></div></div></footer></div></div>
	<script src="https://f.alicdn.com/react/15.4.1/react-with-addons.min.js"></script>
	<script src="https://f.alicdn.com/react/15.4.1/react-dom.min.js"></script>
	<script>
		window.rootPath = '';
  </script>
	<script src="/build/documentation.js"></script>
</body>
</html>